/**
 * author:wos
 * time:2024-1-4
 * title:获取验证码
 */
const svgCaptcha = require('svg-captcha'),
    {getTimestampAfterSeconds} = require('../../utils/timestamp'),
    jwt= require('jsonwebtoken')
async function captcha(ctx, next) {

    const captcha = await svgCaptcha.create({
        size: 4,
        ignoreChars: '0o1ilOI',
        noise:1,
        width:120,
        height:50,
        color:true
        // color:false
    })
    const token = jwt.sign({data:captcha.text, exp:getTimestampAfterSeconds(5*60)}, global.config.secret)

    global.response(ctx, {
        "status":200,
        "code": 200,
        "data": {
            "uuid": token,
            "data":captcha.data
        },
        "msg":'success'
    })
}

module.exports = captcha


